package com.kevin.utility.common;

import java.util.Locale;
import java.util.ResourceBundle;

import javax.servlet.http.HttpServletRequest;

public class LangManagerUtil {

	private LangManagerUtil(){
	}
	     
	public static Locale getCurrentUserLang(String account,HttpServletRequest request){
		Locale defLanguage=(Locale)request.getSession().getServletContext().getAttribute(account);
        if(defLanguage==null){
            defLanguage=request.getLocale();
        }
        return defLanguage;
	}
	
	public static String getCurrentUserLangTag(String account,HttpServletRequest request){
		Locale defLanguage=(Locale)request.getSession().getServletContext().getAttribute(account);
        if(defLanguage==null){
            defLanguage=request.getLocale();
        }
        return defLanguage.toString();
	}
	
	public static ResourceBundle getCurrentUserResourceBundle(String account,HttpServletRequest request,String propertiesPath){
		Locale defLanguage=getCurrentUserLang(account,request);
		ResourceBundle resBundle = ResourceBundle.getBundle(propertiesPath,defLanguage);
		return resBundle;
	}
}
